<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
<head th:include="public/page_css::page_css ('库存转移明细')"/>

<body>
<div class="layui-fluid larry-wrapper">
    <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm1">
        <input type="hidden" th:value="${id}" id="pid" name="id">
    </form>
    <div class="group-button" id="toolbar">
        <a class="layui-btn layui-btn-sm layui-btn-normal" id="addBtn" style=" text-decoration: none;">
            <i class="layui-icon">&#x1005;</i> 新增明细
        </a>
    </div>
    <div class="pro">
        <table id="table1" class="table text-nowrap"></table>
    </div>
</div>
</body>
<div th:include="public/public_js::public_js"></div>

<script th:inline="javascript">
    $(function () {
    })

</script>
<script>
    layui.use(['myform', 'zzpUtils', 'form', 'jquery'], function () {
        window.operateEvent = {
            "click #btn_delete": function (e, value, row, index) {//删除
                btn_delete(row.id);
            }


        }
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery;

        //删除
        function btn_delete(id) {
            var pass = {};
            var list = [];
            list.push(id);
            pass.ids = list;
            pass.id = $("#pid").val();
            zzpUtils.confirm("您将删除选择的数据", function (index) {
                zzpUtils.action({
                    url: "/wmsstockmove/bjDeleteMx",
                    data: JSON.stringify(pass),
                    success: function (data) {
                        setTimeout(function () {
                            layer.msg(data.title);
                        }, 500);
                        zzpUtils.refreshTable("#table1");
                    }, error: function (xhr, textStatus) {
                        console.log(textStatus);
                        console.log(xhr)
                    }
                })
            })
            return false;

        }
        $("#addBtn").on('click',function () {
            var url, dialog = zzpUtils.dialogBtn;
            layer.open({
                title: "新增库存移动明细",
                type: 2,
                area: ['95%', '95%'],
                content: "/zxsdwms/kczy/addkczyMx?id="+$("#pid").val(),
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table1");
                }
            });
        });


        var $table = zzpUtils.table({
            elem: '#table1',
            isApi: true,
            pagination: true,
            url: '/wmsstockmove/getWmsStockMoveDetail',
            columns: [{
                field: '',
                checkbox: true
            }, {
                field: 'hpbh',
                title: '货品编号'
            }, {
                field: 'hpmc',
                title: '货品名称'
            }, {
                field: 'dwms',
                title: '单位描述'
            }, {
                field: 'hpph',
                title: '货品批次'
            }, {
                field: 'hpscrq',
                title: '生产日期'
            }, {
                field: 'show_kwid',
                title: '移动前库位'
            }, {
                field: 'kydsl',
                title: '可移动数量'
            }, {
                field: 'show_ydhkwid',
                title: '目标储位'
            }, {
                field: 'zysl',
                title: '移动数量'
            }, {
                field: 'caozuo',
                title: '可用操作',
                width: 200,
                events: operateEvent,
                formatter: operateFormatter1
            }],
            queryParams: function () {//查询条件
                return zzpUtils.getFormJson($("#searchForm1"));
            },
        });

        /*表格右侧按钮*/
        function operateFormatter1(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-xs" id="btn_delete" style="text-decoration:none;">删除</a>'
            ].join('')
        }
    });

</script>
</html>